﻿namespace Dcms.UpdateModule
{
    using Dcms.BLL;
    using Dcms.Common;
    using Dcms.Model;
    using System;
    using System.Web;

    public class DcmsGuestBook : IHttpHandler
    {
        public void ProcessRequest(HttpContext ctx)
        {
            Dcms_GuestBookBLL kbll = new Dcms_GuestBookBLL();
            Dcms_GuestBookModel model = new Dcms_GuestBookModel();
            model.GuestBook_AddTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"));
            model.GuestBook_Content = DcmsRequest.GetFormString("Content");
            model.GuestBook_CateId = DcmsRequest.GetFormInt("CateId", 0);
            model.GuestBook_ReplyContent = "";
            model.GuestBook_ReplyTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"));
            model.GuestBook_State = "0";
            model.GuestBook_Title = DcmsRequest.GetFormString("Title");
            model.GuestBook_UserEmail = DcmsRequest.GetFormString("UserEmail");
            model.GuestBook_UserIM = DcmsRequest.GetFormString("UserIM");
            model.GuestBook_UserIp = DcmsRequest.GetIP();
            model.GuestBook_UserName = DcmsRequest.GetFormString("UserName");
            model.GuestBook_UserPic = DcmsRequest.GetFormString("UserPic");
            model.GuestBook_UserTel = DcmsRequest.GetFormString("UserTel");
            model.GuestBook_ExFlag1 = DcmsRequest.GetFormString("ExFlag1");
            model.GuestBook_ExFlag2 = DcmsRequest.GetFormString("ExFlag2");
            model.GuestBook_ExFlag3 = DcmsRequest.GetFormString("ExFlag3");
            model.GuestBook_ExFlag4 = DcmsRequest.GetFormString("ExFlag4");
            model.GuestBook_ExFlag5 = DcmsRequest.GetFormString("ExFlag5");
            model.GuestBook_ExFlag6 = DcmsRequest.GetFormString("ExFlag6");
            model.GuestBook_ExFlag7 = DcmsRequest.GetFormString("ExFlag7");
            model.GuestBook_ExFlag8 = DcmsRequest.GetFormString("ExFlag8");
            model.GuestBook_ExFlag9 = DcmsRequest.GetFormString("ExFlag9");
            model.GuestBook_ExFlag10 = DcmsRequest.GetFormString("ExFlag10");
            if (model.GuestBook_Title.Length <= 0 || model.GuestBook_Content.Length <= 0)
                Jscript.AlertAndBack(DcmsRequest.GetFormString("errorMessage"));
            else
            {
                kbll.AddModel(model);
                Jscript.AlertAndRedirect(DcmsRequest.GetFormString("successMessage"), DcmsRequest.GetFormString("successUrl"));
            }
        }

        public bool IsReusable
        {
            get
            {
                return true;
            }
        }
    }
}

